package com.hades.xq.seckill.base;

import java.io.Serializable;

/**
 * @ClassName CommonReturnType
 * @Description 统一返回数据
 * @Author Hades
 * @Date 2019-03-19:18:27
 * @Version V1.0.0
 */
public class CommonReturnType implements Serializable {

    public final static Integer SUCCESS = 1;
    public final static Integer FAILED = 0;

    private String msg;

    private Integer status;

    private Object data;


    public static CommonReturnType create(Object result, String msg) {
        return CommonReturnType.create(result, SUCCESS, msg);
    }

    public static CommonReturnType createFail(Object result, String msg) {
        return CommonReturnType.create(result, FAILED, msg);
    }

    public static CommonReturnType create(Object result, Integer status, String msg) {
        CommonReturnType commonReturnType = new CommonReturnType();
        commonReturnType.setData(result);
        commonReturnType.setStatus(status);
        commonReturnType.setMsg(msg);
        return commonReturnType;
    }


    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "CommonReturnType{" +
                "msg='" + msg + '\'' +
                ", status=" + status +
                ", data=" + data +
                '}';
    }
}
